home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-I386 / FIXMAP.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  3KB  |  99 lines

  1. /*
  2.  * fixmap.h: compile-time virtual memory allocation
  3.  *
  4.  * This file is subject to the terms and conditions of the GNU General Public
  5.  * License.  See the file "COPYING" in the main directory of this archive
  6.  * for more details.
  7.  *
  8.  * Copyright (C) 1998 Ingo Molnar
  9.  */
  10.  
  11. #ifndef _ASM_FIXMAP_H
  12. #define _ASM_FIXMAP_H
  13.  
  14. #include <linux/config.h>
  15. #include <linux/kernel.h>
  16. #include <asm/page.h>
  17.  
  18. /*
  19.  * Here we define all the compile-time 'special' virtual
  20.  * addresses. The point is to have a constant address at
  21.  * compile time, but to set the physical address only
  22.  * in the boot process. We allocate these special  addresses
  23.  * from the end of virtual memory (0xfffff000) backwards.
  24.  * Also this lets us do fail-safe vmalloc(), we
  25.  * can guarantee that these special addresses and
  26.  * vmalloc()-ed addresses never overlap.
  27.  *
  28.  * these 'compile-time allocated' memory buffers are
  29.  * fixed-size 4k pages. (or larger if used with an increment
  30.  * bigger than 1) use fixmap_set(idx,phys) to associate
  31.  * physical memory with fixmap indices.
  32.  *
  33.  * TLB entries of such buffers will not be flushed across
  34.  * task switches.
  35.  */
  36.  
  37. /*
  38.  * on UP currently we will have no trace of the fixmap mechanizm,
  39.  * no page table allocations, etc. This might change in the
  40.  * future, say framebuffers for the console driver(s) could be
  41.  * fix-mapped?
  42.  */
  43. enum fixed_addresses {
  44. #ifdef CONFIG_X86_LOCAL_APIC
  45.     FIX_APIC_BASE,    /* local (CPU) APIC) -- required for SMP or not */
  46. #endif
  47. #ifdef CONFIG_X86_IO_APIC
  48.     FIX_IO_APIC_BASE,
  49. #endif
  50. #ifdef CONFIG_X86_VISWS_APIC
  51.     FIX_CO_CPU,    /* Cobalt timer */
  52.     FIX_CO_APIC,    /* Cobalt APIC Redirection Table */ 
  53.     FIX_LI_PCIA,    /* Lithium PCI Bridge A */
  54.     FIX_LI_PCIB,    /* Lithium PCI Bridge B */
  55. #endif
  56.     __end_of_fixed_addresses
  57. };
  58.  
  59. extern void set_fixmap (enum fixed_addresses idx, unsigned long phys);
  60.  
  61. /*
  62.  * used by vmalloc.c.
  63.  *
  64.  * Leave one empty page between vmalloc'ed areas and
  65.  * the start of the fixmap, and leave one page empty
  66.  * at the top of mem..
  67.  */
  68. #define FIXADDR_TOP    (0xffffe000UL)
  69. #define FIXADDR_SIZE    (__end_of_fixed_addresses << PAGE_SHIFT)
  70. #define FIXADDR_START    (FIXADDR_TOP - FIXADDR_SIZE)
  71.  
  72. #define __fix_to_virt(x)    (FIXADDR_TOP - ((x) << PAGE_SHIFT))
  73.  
  74. extern void __this_fixmap_does_not_exist(void);
  75.  
  76. /*
  77.  * 'index to address' translation. If anyone tries to use the idx
  78.  * directly without tranlation, we catch the bug with a NULL-deference
  79.  * kernel oops. Illegal ranges of incoming indices are caught too.
  80.  */
  81. extern inline unsigned long fix_to_virt(const unsigned int idx)
  82. {
  83.     /*
  84.      * this branch gets completely eliminated after inlining,
  85.      * except when someone tries to use fixaddr indices in an
  86.      * illegal way. (such as mixing up address types or using
  87.      * out-of-range indices).
  88.      *
  89.      * If it doesn't get removed, the linker will complain
  90.      * loudly with a reasonably clear error message..
  91.      */
  92.     if (idx >= __end_of_fixed_addresses)
  93.         __this_fixmap_does_not_exist();
  94.  
  95.         return __fix_to_virt(idx);
  96. }
  97.  
  98. #endif
  99.